from utils.serializer import ModelSerializer
from app.user.models import Role
from flask_restplus import fields
from .permission import PermissionSerializer


class RoleSerializer(ModelSerializer):
    permissions = fields.List(fields.Nested(PermissionSerializer().fields_model()))

    class Meta:
        model = Role
        fields = ('id', 'name', 'key', 'desc', 'permissions')


class RoleEasySerializer(ModelSerializer):
    class Meta:
        model = Role
        fields = ('id', 'name', 'key', 'desc')
